//
//  ForgetPwdController.m
//  LazyCat
//
//  Created by jike on 15/9/25.
//  Copyright (c) 2015年 zhanshu. All rights reserved.
//

#import "ForgetPwdController.h"
#import "NJKWebViewProgress.h"
#import "NJKWebViewProgressView.h"

@interface ForgetPwdController ()<UIWebViewDelegate,NJKWebViewProgressDelegate>

{
    NJKWebViewProgressView *_progressView;
    NJKWebViewProgress *_progressProxy;
}

@property (nonatomic, retain) UIWebView *webView;

@end

@implementation ForgetPwdController
- (void)backAction:(UIButton *)btn {
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    //导航
    [self initNav:self.strTitle doBack:YES];
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 63, ScreenWidth, 1)];
    lineView.backgroundColor = [UIColor lightGrayColor];
    lineView.alpha = 0.2;
    [self.navBar addSubview:lineView];
    // 创建视图
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64)];
    self.webView.delegate = self;
    [self.webView.scrollView setBounces:YES];
    [self.webView.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
    [self.webView.scrollView setBounces:NO];// 边缘弹动效果
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.forgetPwdUrl]]];// 加载请求
    [self.view addSubview:self.webView];
    [self loadMessPart];//加载进度条
}
- (void)loadMessPart {
    _progressProxy = [[NJKWebViewProgress alloc] init];
    _webView.delegate = _progressProxy;
    _progressProxy.webViewProxyDelegate = self;
    _progressProxy.progressDelegate = self;
    CGFloat progressBarHeight = 2.f;
    CGRect barFrame = CGRectMake(0, 64, ScreenWidth, progressBarHeight);
    _progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame];
    [self.view addSubview:_progressView];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {//进度条
    [_progressView setProgress:1 animated:NO];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    if (kNetworkNotReachability) {
        [[MessShowView share] showWithMess:@"网络不给力"];
        _webView.hidden = YES;
        [_progressView setProgress:2 animated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end
